package com.hongtai.mysql_json_study.service;

import com.alibaba.fastjson.JSONObject;
import com.hongtai.mysql_json_study.dao.InfoDAO;
import com.hongtai.mysql_json_study.pojo.Info;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;

@org.springframework.stereotype.Service
public class Service {

    @Autowired
    InfoDAO infoDAO;

    public int add1(){
        Info info = new Info();
        JSONObject obj = new JSONObject();
        obj.put("a","aaa");
        obj.put("b","小肥仔");
        info.setJsonobj(obj);
        return infoDAO.add1(info);
    }
    public int add2(){
        String xixixi = "192.168.1.1";
        return infoDAO.add2(xixixi);
    }

    public String findIpById(){
        return infoDAO.findIpById(2);
    }

    public String findKeysById(){
        return infoDAO.findKeysById(3);
    }

    public int deleteKey(){
        return infoDAO.deleteKey(3);
    }
    public int changeKey(){
        return infoDAO.changeKey("ip","192.168.1.123",3);
    }

    public Info findById(){
        return infoDAO.findById(1);
    }
    public ArrayList<Info> findAll(){
        return infoDAO.findAll();
    }
}
